﻿@{
    ViewData["Title"] = "添加平面设备报文处理配置";
    Layout = "_Edit";
}
@section css{
    <style>

        .select-editor {
            position: relative;
            height: 30px;
            overflow: hidden;
            border: solid 1px #ccc;
        }

            .select-editor select {
                position: absolute;
                top: 0px;
                left: 0px;
                border: none;
                width: 100%;
                margin: 0;
            }

            .select-editor input {
                position: absolute;
                top: 0px;
                left: 0px;
                border: none;
                width: 90%;
            }

                .select-editor select:focus,
                .select-editor input:focus {
                    outline: none;
                }

            .select-editor[disabled] input {
                background-color: rgb(235, 235, 228);
            }

    </style>

       }
    <article class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-add">
            <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备编号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box select-editor">
                        <select class="select" size="1"  style="height:30px" >
                            <option value="">--请选择--</option>
                            @foreach (var item in Model.EquipmentSearchDatas)
                        {
                            if (Model.EquipmentCode == item.EquipmentCode)
                            {
                                <option value="@item.EquipmentCode" selected>@item.EquipmentCode</option>
                            }
                            else
                            {
                                <option value="@item.EquipmentCode">@item.EquipmentCode</option>
                            }
                        }
                    </select>
                    <input type="text" name="EquipmentCode" id="EquipmentCode" value="@Model.EquipmentCode" style="height:30px" />
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>PLC动作类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.PlcActionType" placeholder="" id="PlcActionType" name="PlcActionType">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>WCS动作类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.WcsActionType" placeholder="" id="WcsActionType" name="WcsActionType">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>平面设备业务类定义名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.PlanarProcessServiceName" placeholder="" id="PlanarProcessServiceName" name="PlanarProcessServiceName">
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operate()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

    <script>

        $.fn.selectEditor = function() {
            return this.each(function() {
                var self = this
                var $editor = $(self)
                var $select = $editor.find('select')
                var $input = $editor.find('input')

                if ($input.size() < 1 || $select.size() < 1) {
                    return
                }

                $select.on('change', function() {
                    var self = this
                    var option = self.options[self.selectedIndex]
                    if (!option) {
                        return
                    }

                    $input.val(option.value)
                })
            })
        }

        $('.select-box').selectEditor()




        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        function operate() {
            var EquipmentCode = $("#EquipmentCode").val();
            if (EquipmentCode == null || EquipmentCode == "") {
                popupAlert('请选择设备编号', 2, function(data) { layer.close(data); });
                return;
            }

            var PlcActionType = $("#PlcActionType").val();
            if (PlcActionType == null || PlcActionType == "") {
                popupAlert('请输入PLC动作类型', 2, function(data) { layer.close(data); });
                return;
            }
            var WcsActionType = $("#WcsActionType").val();
            if (WcsActionType == null || WcsActionType == "") {
                popupAlert('请输入WCS动作类型', 2, function(data) { layer.close(data); });
                return;
            }
            var PlanarProcessServiceName = $("#PlanarProcessServiceName").val();
            if (PlanarProcessServiceName == null || PlanarProcessServiceName == "") {
                popupAlert('请输入平面设备业务类定义名称', 2, function(data) { layer.close(data); });
                return;
            }
            SubmitFormForAjax("/planarprocessservicemap/operateplanarproceservicemapinfo", $("#form-add").serialize(), function(data) {
                if (data.result) {
                    popupAlert('提交成功', 1, function() { closePageLayer(true); });
                } else {
                    popupAlert(data.message, 2, function(data) { layer.close(data); });
                }
            }, true);
        }
    </script>
}